const formatDateYMDHM = (date) => `${date.getFullYear()}-${(date.getMonth() + 1)<10?'0'+(date.getMonth() + 1):date.getMonth() + 1}-${(date.getDate())<10?'0'+(date.getDate()):date.getDate()} ${(date.getHours())<10?'0'+(date.getHours()):date.getHours()}:${(date.getMinutes())<10?'0'+(date.getMinutes()):date.getMinutes()}`;
const parseToDateYMDHM = (val) => {
	const format = '{y}/{m}/{d} {h}:{i}'
	let date = new Date(val)
	const formatObj = {
		y: date.getFullYear(),
		m: date.getMonth() + 1,
		d: date.getDate(),
		h: date.getHours(),
		i: date.getMinutes()
	}
	return strTime(format,formatObj).toString()
}
const strTime = (format,formatObj) => format.replace(/{(y|m|d|h|i|s|w)+}/g, (result, key) => {
	let value = formatObj[key]
	if (result.length > 0 && value < 10) {
		value = '0' + value
	}
	return value
})
/** 
 * file转base64
*/
const blobToDataURL = (blob, cb) => {
    let reader = new FileReader();
    reader.onload = function (evt) {
        let base64 = evt.target.result;
        cb(base64);
    };
    reader.readAsDataURL(blob);
};
const hasNull = (params) => {
	var keys = Object.keys(params);
	for (var i = 0; i < keys.length; i++) {
		var obj = params[keys[i]];
		console.log("keys[i]",keys[i])
		console.log("obj",obj)
		// console.log(keys[i],obj,obj == "")
		// if(obj===0){
		// 	return false;
		// }
		if (obj === null || obj === "" || obj == []) {
			return true;
		}
	}
	return false;
}

export default{
    formatDateYMDHM,
	parseToDateYMDHM,
    blobToDataURL,
    hasNull
}